28. Add The Other Team - Java
Add The Other Team - Java
Question:
Start Quiz:
Solution:
INSTRUCTOR NOTE:
Step 1 : Add the Display Code
Add the following method inside of MainActivity.java
/** * Displays the given score for Team B. */ public void displayForTeamB(int score) { TextView scoreView = (TextView) findViewById(R.id.team_b_score); scoreView.setText(String.valueOf(score)); }
Step 2 : Set the Correct ID
Set Team B’s score TextView to the id team_b_score
using the id attribute. This is the code you will use:
android:id="@+id/team_b_score"
Now you can use the code displayForTeamB()
to show Team B’s score in the TextView with the id team_b_score
. For example displayForTeamB(12)
will display a score of 12.